<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Campus</h2>
        </ui:define>

        <ui:define name="body">

            <p:panel styleClass="container_24 clearfix">
                <div class="buttonAction" style="float: right">
                    <p:button value="Adicionar" href="criarsecretaria.xhtml" icon="ui-icon-plusthick"
                              styleClass="ui-priority-primary"/>
                </div>
                <br/>
            </p:panel>

            <h:form id="secretariaForm" enctype="multipart/form-data">            
                <p:panel styleClass="container_24 clearfix">
                    <h2>Filtros</h2>

                    <p:outputLabel value="Nome:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretaria.nome}"/>
                    <div class="clear"/>
                    <p:outputLabel value="Diretor:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretaria.nomeSecretario}"/>
                    <div class="clear"/>
                    <p:outputLabel value="Sigla:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretaria.sgl}"/>

                    <div class="buttonAction">
                        <p:commandButton id="bt_pesquisar" value="Pesquisar" icon="ui-icon-search"
                                         update="tableSecretaria"
                                         actionListener="#{managerPesquisarSecretaria.pesquisarSecretaria()}"
                                         styleClass="ui-priority-primary" />
                        <p:button href="indexsecretaria.xhtml" value="Cancelar" icon="ui-icon-circle-close"/>
                    </div>

                </p:panel>

                <p:panel styleClass="container_24 clearfix">
                    <p:dataTable id="tableSecretaria" var="item" value="#{managerPesquisarSecretaria.secretarias}" 
                                 styleClass="grid_24" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;"
                                 rowKey="#{item.id}" rows="5" paginator="true"  
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            <p:outputLabel value="Campus" />
                        </f:facet>
                        <p:column headerText="Ação" width="10px;" > 
                            <p:button title="Visualizar" 
                                      href="visualizarsecretaria.xhtml?secVi=#{item.id}"
                                      icon="ui-icon-zoomin"/> 
                            <p:commandButton title="Excluir" oncomplete="dlg.show();" 
                                             update="@form" icon="ui-icon-trash">
                                <f:setPropertyActionListener target="#{managerPesquisarSecretaria.secretariaExcluir}" value="#{item}" />
                            </p:commandButton>
                        </p:column>
                        <p:column headerText="Nome"> 
                            #{item.nome}
                        </p:column>
                        <p:column headerText="Diretor"> 
                            #{item.nomeSecretario}
                        </p:column>

                    </p:dataTable>
                </p:panel>

                <p:panel id="paneldlg">
                    <p:dialog id="iddlg" header="Exclusão" widgetVar="dlg" modal="true"
                              appendToBody="true" height="20"
                              showEffect="fade" hideEffect="fade" resizable="false">
                        <h:outputText value="Deseja excluir este registro ?" /> <br/> 
                        <f:facet name="footer">
                            <div class="buttonAction">
                                <p:commandButton value="Sim" id="idb"
                                                 update="@form, :secretariaForm:tableSecretaria"
                                                 icon="ui-icon-check" onsuccess="dlg.hide()"
                                                 actionListener="#{managerPesquisarSecretaria.deletar()}" />
                                <p:commandButton value="Não" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                            </div>
                        </f:facet>
                    </p:dialog>   
                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
